<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>短剧列表</title>
    <script src="./js/ajax.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        .w {
            width: 1200px;
            margin: auto;
        }

        .container {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }

        .container li {
            list-style-type: none;
            flex-basis: 200px;
            flex-grow: 1;
            height: fit-content;
            padding: 10px;
            box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
            text-align: center;
            cursor: pointer;
        }

        .container li img {
            width: 100%;
        }

        .container li h4 {
            margin: 10px;
        }

        .link {
            text-decoration: none;
            border: 1px solid red;
            display: inline-block;
            width: 100px;
            height: 36px;
            text-align: center;
            line-height: 36px;
            color: red;
        }

        .container li:hover>.link {
            background-color: red;
            color: #fff;
        }
    </style>
</head>

<body>
    <h1 class="w">短剧列表</h1>
    <!-- <a target="_blank" href="./detail.html?eid=10835">查看详情</a> -->
    <ul class="container w">
        <!-- <li>
            <img src="https://static.zhonglian.com/upload/200004/2024/03/15/11/0df9a097fa956b736959a109b29c0266.png"
                alt="">
            <h5>深情罪爱，陆少别虐了</h5>
        </li> -->
    </ul>
    <script>
        var container=document.querySelector('.container')
        ajax({
            url: "http://playlet.zonelian.com:5501/api/playlet/random",
            data: {
                page: 1, limit: 20, zlsj: 'zlsj'
            },
            success: function (res) {
                // console.log(res.data.data);
                if (res.code == 200) {
                    var html = ''
                    res.data.data.forEach(function (item) {
                        // location.href='./detail.html?eid=${item.eid}'
                        html += `
                            <li onclick="window.open('./detail.html?eid=${item.eid}')">
                                <img src="${item.img}" alt="">
                                <h5>${item.title}</h5>
                            </li>
                        `
                    })
                    // 打开一个全新的窗口
                    // window.open('要打开的网页地址')
                    // 将拼接好的html渲染到浏览器中
                    container.innerHTML=html
                }

            }
        })
    </script>
</body>

</html>